package br.com.sisat.util;

import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class HttpUtil {
	
	private static HttpUtil httpUtil;
	
	private HttpUtil() {
		
	}

	public static HttpUtil getInstance() {
		if(httpUtil==null){
			httpUtil = new HttpUtil();
		}
		return httpUtil;
	}
	
	public String getRequestParameter(String key){
		return getRequest().getParameter(key);
	}
	
	public void setRequestAttribute(String key,Object value){
		 getRequest().setAttribute(key, value);
	}

	public HttpSession getSession(){
		return getRequest().getSession();
	}

	public void setSessionAttribute(String key, Object value){
		 getSession().setAttribute(key, value);
	}
	
	public void removeSessionAttribute(String key){
		getSession().removeAttribute(key);
	}
	
	public Object getSessionAttribute(String key){
		return getSession().getAttribute(key);
	}
	
	public HttpServletRequest getRequest() {
		return (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
	}
}
